package com.gsm.controller;

import com.gsm.entity.Result;
import com.gsm.po.Nav;
import com.gsm.service.NavService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 导航列表(Nav)表控制层
 *
 * @author wjq
 * @since 2020-11-25 21:36:26
 */
@RestController
@RequestMapping("nav")
public class NavController {
    @Autowired
    private NavService navService;

    /**
     * 新增
     */
    @PostMapping("nav")
    public Result insertNav(@RequestBody Nav nav) {
        Result result = navService.insertNav(nav);
        return result;
    }

    /**
     * 根据 id 删除数据
     */
    @DeleteMapping("nav/{navId}")
    public Result deleteNavByNavId(@PathVariable("navId") Long navId) {
        Result result = navService.deleteNavByNavId(navId);
        return result;
    }

    /**
     * 根据 id 修改单条数据
     */
    @PutMapping("nav/{navId}")
    public Result updateNavByNavId(@PathVariable("navId") Long navId, @RequestBody Nav nav) {
        nav.setNavId(navId);
        Result result = navService.updateNavByNavId(nav);
        return result;
    }

    /**
     * 根据 id 查询单条数据
     */
    @GetMapping("nav/{navId}")
    public Result selectNavByNavId(@PathVariable("navId") Long navId) {
        Result result = navService.selectNavByNavId(navId);
        return result;
    }

    /**
     * 根据条件查询 List
     */
    @GetMapping("navList")
    public Result selectNavList(Nav nav) {
        Result result = navService.selectNavList(nav);
        return result;
    }

    /**
     * 根据id排序
     */
    @PutMapping("order")
    public Result updateNavShowOrder(@RequestBody List<Long> navIds) {
        Result result = navService.updateNavShowOrder(navIds);
        return result;
    }
}